// const baseUrl = process.env.NODE_ENV === 'development' ? 'https://tapi.kuaidianai.com/api' : 'https://tapi.kuaidianai.com/api' // 测试环境
const baseUrl = process.env.NODE_ENV === 'development' ? 'https://api.kuaidianai.com/api' : 'https://api.kuaidianai.com/api' // 生产环境
const urlParams = new URLSearchParams(window.location.search)
const uploadUrl = baseUrl +'/common/uploadfile'

const textProps = {rows: "1", type:"textarea", autosize: true}

function openWx(uri, afterUrl = ''){
  const url = `${uri}${location.search}${afterUrl}`
  // // 确保在微信环境中打开
  // if (typeof wx !== 'undefined' && wx.miniProgram) {
  //   // 打开新页面，URL为小程序内的页面路径，如：'pages/index/index'
  //   wx.miniProgram.navigateTo({
  //     url: '/routes/WebView/index?url='+ encodeURIComponent(url)
  //   });
  // } else {
  //   alert('请在微信环境中打开');
  // }

  // window.open(url)
  location.href = url
}

function failLogin(res) {
  if (res.code === '0102') {
    this.$toast(res.msg || res.message)

    if (typeof wx !== 'undefined' && wx.miniProgram) {
      // 打开新页面，URL为小程序内的页面路径，如：'pages/index/index'
      wx.miniProgram.reLaunch({ url: '/routes/Login/index' });
    } else {
      alert('请在微信环境中打开');
    }

  }
}



export {
  baseUrl,
  uploadUrl,
  urlParams,
  openWx,
  failLogin,
  textProps
}
